/**
 * 表单数据模型
 */
module.exports = (app) => {
  const { INTEGER, STRING } = app.Sequelize;
  const Hickey = app.model.define(
    "hickey",
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
      },
      type: STRING(50),
      name: STRING(50),
      url: STRING(50),
    },
    {
      timestamps: false,
    }
  );

  Hickey.associate = function () {
    // 一对多
    app.model.Hickey.hasMany(app.model.DataSource, {
      foreignKey: "hickeyId",
      targetKey: "id",
      as: "dateSourceList",
    });
  };

  return Hickey;
};
